﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Malu.Entity;
using MaLu.Data;

namespace MaLu.Framework.Common
{
    public class Util
    {
        public static string ReplaceXml(string str)
        {
            // str = str.Replace("<", "&lt;").Replace(">", "&gt;").Replace("&", "&amp;").Replace("'", "&apos;").Replace("\"", "&quot;");
            return str;
        }
        public static string ReturnXml(string str)
        {
            str = str.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&amp;", "&").Replace("&apos;", "'").Replace("&quot;", "\"");
            return str;
        }

        public static string ReturnSqlValue(string str,DbType type)
        {
            string result = string.Empty;
            switch (type)
            {
                case DbType.Int32:
                    int g = 0;
                    int.TryParse(str, out g);
                    result = g.ToString();
                    
                    break;
                case DbType.Double:
                    float f = 0;
                    float.TryParse(str, out f);
                    result = f.ToString("f2");

                    break;
            
            
            
            
            }
            return result;

        }

        public static string ReturnSqlValue(string str)

        {
            if (str.Trim() != string.Empty)
                return "N'" + str.Trim().Replace("'", "''") + "'";
            else
                return "NULL";

        }
        public static DataTable GetMonth()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("value");
            dt.Columns.Add("text");
            for (int i = 1; i < 12; i++)
            {
                DataRow dr = dt.NewRow();
                dr["value"] = i;
                dr["text"] = i;
                dt.Rows.Add(dr);
            }
            return dt;
        }
      
       
    }
}
